feat: Create clear and sync scripts for prod->dev cloning #2003
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1638
What changes did you make and why did you make them?
/backend/package.jsonfor running thecloneOrSyncCollectionsgs.jsandclearDevCollections.jsscripts with various flags.--mockflag and flags for each supported collection:cloneOrSyncCollectionsgs.js:--projects,--recurring-eventsclearDevCollections.js:--projects,--recurring-events,--events,--checkinsUsage Guide
1. Change to the backend directory:
cd backend2. Use
--mockto preview what will happen (no data will be changed):3. Confirm the output is satisfactory.
4. Remove
--mockto run the operation on the live DEV database:Supported Flags & Environment Variables
For
clearDevCollections:--projectsOnly clear the 'projects' collection--recurring-eventsOnly clear the 'recurringevents' collection--eventsOnly clear the 'events' collection--checkinsOnly clear the 'checkins' collection--allClear all supported collections--mockOnly print what would be deleted, do not delete--helpShow help message and exitFor
cloneOrSyncCollectionsgs:--projectsClone/sync the 'projects' collection--recurring-eventsClone/sync the 'recurringevents' collection--initialInitial clone (insertMany, skip duplicates)--mockOnly print what would be written, do not write--helpShow help message and exitRequires environment variables:
PROD_DB_URI- MongoDB URI for PRODDEV_DB_URI- MongoDB URI for DEVExample Commands
Preview what would be deleted from all collections (no data is changed):
Actually clear the 'projects' collection:
Clone projects and recurring events from PROD to DEV (mock mode):
Clone only recurring events (real operation):